package com.where.test.controller;

import com.where.test.config.OSSPropertiesConfig;
import com.where.test.entity.User;
import com.where.test.sevice.OssUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: where
 * @Date: 2023/02/23/9:18
 * @Description:
 */

//@Api(value="用户controller",tags={"用户操作接口-controller"})
@Api(value="用户controller")
@RestController
@RequestMapping("/test/test")
public class Knife4jController {
    @Autowired
    private OssUtils ossService;

    @ApiOperation(value="获取用户信息",notes="注意问题点")
    @GetMapping("/getUserInfo")
    public void getUserInfo(@ApiParam(name="id",value="用户id",required=true) Long id,
                            @ApiParam(name="username",value="用户名") String username) {
        // userService可忽略，是业务逻辑

    }

    @ApiOperation(value="保存用户信息",notes="注意问题点")
    @GetMapping("/save")
    public User save(@ApiParam(name = "user", value = "userEntity") @RequestBody User user) {
        // userService可忽略，是业务逻辑
        User u = new User();


        return u;
    }

    @GetMapping("/print")
    public void print() {
        String s = new OSSPropertiesConfig().toString();
        System.out.println(s);
    }


    @PostMapping("/upload")
    public String upload(MultipartFile file) {
        try {
            return ossService.upload(file);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    }
}
